package jgcp.master;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

import jgcp.config.Configuration;
/**
 * 
 * @Date 31/05/2009
 * @author Jie Zhao (288654)
 * @version 1.0
 */
public class UserServer implements Runnable {

	private boolean isRunning = true;

	public void run() {
		ServerSocket ss;
		try {
			ss = new ServerSocket(Configuration.getInstance().getMasterPort());
			System.out.println("User service started on port:"+Configuration.getInstance().getMasterPort());
			while (isRunning) {
				try{
					Socket cs = ss.accept();
					new UserHandler(cs).start();
				}
				catch (IOException e) {
					e.printStackTrace();
				}
			}

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	public void stop() {
		isRunning = false;
	}


}
